const { execSQL } = require('../db/mysql');

// 单词书相关的方法

// 获取书籍列表
const getBookList = (author, keyword, status, type) => {
    let sql = `select * from BK where 1=1 `;
    if (status !== 'all') {
        sql += `and status='${status}' `;
    }
    if (type) {
        sql += `and type='${type}' `;
    }
    if (author) {
        sql += `and author='${author}' `;
    }
    if (keyword) {
        sql += `and name like '%${keyword}%'`;
    }
    return execSQL(sql);
}

// 获取书籍章节列表
const getBookChapter = (id) => {
    let sql = `select * from BK_CHAPTER where book_id=${id}`;
    return execSQL(sql);
}




module.exports = {
    getBookList,
    getBookChapter,
}